package we3d.filter 
{
	import flash.display.BitmapData;
	import flash.geom.Rectangle;
	import we3d.View3d;
	
	public class ZBuffer extends BackgroundFilter 
	{
		public function ZBuffer (w:int=0, h:int=0) {
			_width = w;
			_height = h;
		}
		
		public var bmp:BitmapData;
		private var _width:int;
		private var _height:int;
		private var bgcol:uint = 0;
		
		public function setSize (w:int, h:int) :void {
			_width = w;
			_height = h;
			createBitmap();
		}
		
		public override function initialize (view:View3d) :void {
			if(_width == 0) _width = view.scene.cam.width || view.width;
			if(_height == 0) _height = view.scene.cam.height || view.height;
			createBitmap();
		}
		
		public override function initFrame (view:View3d) :void {
			bmp.fillRect(bmp.rect, bgcol);
		}
		
		private function createBitmap () :void {
			bmp = new BitmapData(_width, _height, false, bgcol);
		}
		
	}
}